#include "StdAfx.h"
#include "ElementHidingCollection.h"
#include <boost/algorithm/string.hpp>
#include "utils.h"
using namespace std;

CElementHidingCollection::CElementHidingCollection()
{

}

CElementHidingCollection::CElementHidingCollection(CElementHidingCollection&& elem)

{

}

//Add element hiding rule to collection
//returns true if was succesfully added and false otherwise
bool CElementHidingCollection::Add(string domain, string selector)
{
	if(domain.empty())
	{
		if(*selector.begin() == '#')	//id
		{
			wstring id = toStdWString(string(selector.begin()+1, selector.end()));
			_advIdElements.push_back(id);
			return true;
		}
		else if(*selector.begin() == '.')	//class
		{
			wstring className = toStdWString(string(selector.begin()+1, selector.end()));
			_advClassElements.push_back(className);
			return true;
		}
		else
		{
			wstring other = toStdWString(selector);
			_advOtherElements.push_back(other);
			return true;
		}
	}
	else
	{
		//if(*selector.begin() == '#')	//id
		//{
		//	wstring id = toStdWString(string(selector.begin()+1, selector.end()));
		//	_advDomainIdElements.push_back(DomainIdElementHidingRule(toStdWString(domain), id));
		//	return true;
		//}
		//else if(*selector.begin() == '.')	//class
		//{
		//	wstring className = toStdWString(string(selector.begin()+1, selector.end()));
		//	_advDomainClassElements.push_back(DomainClassElementHidingRule(toStdWString(domain), className));
		//	return true;
		//}
		//else
		//{
		//	wstring other = toStdWString(selector);
		//	_advDomainOtherElements.push_back(GeneralElementHidingRule(toStdWString(domain), other));
		//	return true;
		//}
	}
	return false;
}

const vector<wstring>& CElementHidingCollection::GetAdvertIdElements() const
{
	return _advIdElements;
}

const vector<wstring>& CElementHidingCollection::GetAdvertClassElements() const
{
	return _advClassElements;
}
